var dataTable;
	$(function(){
		$("#${classKey}_query").on("click",function(){
			${classKey}Search();
		});
		$("#${classKey}_add").on("click",function(){
			${classKey}Add();		
		});
		$("#${classKey}_edit").on("click",function(){
			${classKey}Eidt();
		});
		$("#${classKey}_detail").on("click",function(){
			${classKey}Detail();
		});
		$("#${classKey}_delete").on("click",function(){
			${classKey}Delete();
		});
		$(document).on("keypress",function(event){
			if(event){
	   			if(event.keyCode==13 || event.keyCode==0){
	   			    setTimeout(${classKey}Search,300); 
	  		 	}
	  		}
		});
	});
	$(document).ready(function(){
		init${UpperKey}Datagrid(contextPath+'${urlPrefix}/getListData.json');
	});
	/*查询${ZhKey}*/
	function ${classKey}Search(){
		var queryParams = $('#${classKey}_table').datagrid('options').queryParams;  
        /* 此处添加自己的查询条件，类似
        queryParams.lgName = $("#search_lgName").val();  
        */
        //重新加载datagrid的数据  
        $("#${classKey}_table").datagrid('reload');  
	}
	
	/*点击${ZhKey}新增按钮*/
	function ${classKey}Add(){
		openWindow(contextPath+"${urlPrefix}/toAdd${UpperKey}.htm",'${ZhKey}新增');
	}
	/*点击${ZhKey}编辑按钮*/
	function ${classKey}Eidt(){
		var sel=is${UpperKey}Selected();
		if(sel){
			openWindow(contextPath+"${urlPrefix}/toEdit${UpperKey}.htm?${primaryKey}="+sel.${primaryKey},'${ZhKey}编辑');
		}
	}
	/*点击${ZhKey}明细按钮*/
	function ${classKey}Detail(){
		var sel=is${UpperKey}Selected();
		if(sel){
			openWindow(contextPath+"${urlPrefix}/view${UpperKey}Detail.htm?${primaryKey}="+sel.${primaryKey},'${ZhKey}明细');
		}
	}
	/*点击${ZhKey}删除按钮*/
	function ${classKey}Delete(){
		var sel=is${UpperKey}Selected();
		if(sel){
		    $.messager.confirm('删除${ZhKey}', '您确认要删除该${ZhKey}吗?', function(r){
                if (r){
                	$.ajax({
        				url:contextPath+"${urlPrefix}/delete${UpperKey}.json?${primaryKey}="+sel.${primaryKey},
        				dataType:"json",
        				success:function(data){
        					//清除所有选择
        					$('#${classKey}_table').datagrid('clearSelections');
        					$.INFO(data.message,closeWindow);
        				},
        				error:function(data){
        					$.ERROR(ajaxError+JSON.stringify(data));
        				}
        			});
                }
            });
		}
	}
	/*是否有${ZhKey}记录被选中*/
	function is${UpperKey}Selected(){
		var sel=$.selected("${classKey}_table");
		if(null == sel){
			$.ALERT('请选择${ZhKey}记录');
			return false;
		}
		return sel;
	}
	/*初始化${ZhKey}datagrid*/
	function init${UpperKey}Datagrid(_url){
		dataTable=$("#${classKey}_table").datagrid({
			fit:true,
			title:'${ZhKey}信息',
			url:_url,
			iconCls:'icon-ok',
			nowrap: true,
			autoRowHeight: false,
			resizable:true,
			striped: true,
			collapsible:true,
			remoteSort: true,
			singleSelect:true,
			idField:'${primaryKey}',				
			collapsible:false,
			pagination:true,pageSize:10,
			rownumbers:true,
			columns:[[
				<#list fieldList as field>
				  <#if field.priKey?c ='false'>
				  	{field:'${field.name}',title:'${field.comment}',align:'center',resizable:false,width:'${width}'}<#if field_has_next>,</#if>
				  </#if>
				</#list>
			]],
			toolbar:'#toolbar_${classKey}',
			onBeforeLoad:function(data){
			},
			onLoadError:function(data){
				alert(JSON.stringify(data));
			}
		});
	}